//
//  CaseDetailViewController.m
//  e律师
//
//  Created by 韦淋 on 2017/5/16.
//  Copyright © 2017年 test. All rights reserved.
//

#import "CaseDetailViewController.h"



@interface CaseDetailViewController ()<UITableViewDataSource,UITableViewDelegate>



@property (nonatomic, weak) NSArray *titleArray;
@property (nonatomic, weak) NSArray *imageArray;
@property (nonatomic, strong) NSDictionary *tollMethod;
@property (nonatomic, strong) NSArray *ajlxArr;
@property (nonatomic, strong) UITableView *caseTableView;
@end

@implementation CaseDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    if (self.caseDetailFlag == 0) {
        self.barTitleLable.text = @"案件详情";
    }
    if (self.caseDetailFlag == 4) {
        self.barTitleLable.text = @"案件审批";
    }
    if (self.caseDetailFlag == 5) {
        self.barTitleLable.text = @"案件审批";
    }
    NSLog(@"caseDetail = %@",self.caseDetailDic);
    [self getUI];
}
- (void)getUI{
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view insertSubview:self.caseTableView atIndex:0];
}
#pragma mark - Method
- (void)postMessage:(NSInteger )tag{
    NSString *theme = [NSString string];
    NSString *content = [NSString string];
    if (tag == 500) {
        theme = @"主任收案审批通过";
        content = [NSString stringWithFormat:@"您办理的《%@》主任收案审批已通过！将移交财务审批！", self.caseDetailDic[@"ah_number"]];
    }
    if (tag == 501) {
        theme = @"收案审批通过";
        content = [NSString stringWithFormat:@"您办理的《%@》收案审批已通过！案件已收案！", self.caseDetailDic[@"ah_number"]];
    }
    if (tag == 502) {
        theme = @"收案审批未通过";
        content = [NSString stringWithFormat:@"您办理的《%@》收案审批未通过！请注意查看！", self.caseDetailDic[@"ah_number"]];
    }
    if (tag == 600) {
        theme = @"收案审批通过";
        content = [NSString stringWithFormat:@"您办理的《%@》收案审批已通过！案件已收案！", self.caseDetailDic[@"ah_number"]];
    }
    if (tag == 601) {
        theme = @"收案审批未通过";
        content = [NSString stringWithFormat:@"您办理的《%@》收案审批未通过！请注意查看！", self.caseDetailDic[@"ah_number"]];
    }
    if (tag == 700) {
        theme = @"主任结案审批通过";
        content = [NSString stringWithFormat:@"您办理的《%@》主任结案审批已通过！将移交财务审批！", self.caseDetailDic[@"ah_number"]];
    }
    if (tag == 701) {
        theme = @"结案审批通过";
        content = [NSString stringWithFormat:@"您办理的《%@》结案审批已通过！案件已结案！", self.caseDetailDic[@"ah_number"]];
    }
    if (tag == 702) {
        theme = @"结案审批未通过";
        content = [NSString stringWithFormat:@"您办理的《%@》结案审批未通过！请注意查看！", self.caseDetailDic[@"ah_number"]];
    }
    if (tag == 800) {
        theme = @"结案审批通过";
        content = [NSString stringWithFormat:@"您办理的《%@》结案审批已通过！案件已结案！", self.caseDetailDic[@"ah_number"]];
    }
    if (tag == 801) {
        theme = @"结案审批未通过";
        content = [NSString stringWithFormat:@"您办理的《%@》结案审批未通过！请注意查看！", self.caseDetailDic[@"ah_number"]];
    }
    
    NSDictionary *dic = @{
                          @"theme":theme,
                          
                          @"content":content,
                          
                          @"company_id":[InfoSingleTon personInfoSingleTon].infoDic[@"cid"],
                          
                          @"glid":self.caseDetailDic[@"id"],
                          
                          @"accepter_id":self.caseDetailDic[@"create_id"],
                          
                          @"create_id":[InfoSingleTon personInfoSingleTon].infoDic[@"user"][@"id"],
                          
                          @"create_name":[InfoSingleTon personInfoSingleTon].infoDic[@"user"][@"name"],
                          
                          @"create_date":@"2017-07-18",
                          
                        
                          };
    NSLog(@"dic = %@",dic);
    [NetworkingManager postUrl:ADDMESSAGE_URL dic:dic Succeed:^(id responseData) {
        NSLog(@"postMessageSuccess:%@",responseData);
    } failure:^(NSError *error) {
        NSLog(@"postMessageError:%@",error);
    }];
}
#pragma mark - Button Target
- (void)action_Click:(UIButton *)sender{
    if (self.caseDetailFlag == 0) {
        if (sender.tag == 100) {
            NSLog(@"收案申请 ");
            [MBProgressHUD showHUDAddedTo:self.view animated:YES];
            [NetworkingManager postUrl:ALTERCASESTATE_URL dic:@{@"id":self.caseDetailDic[@"id"],@"update_date":@"2017-7-25",@"case_state":@"2"} Succeed:^(id responseData) {
                NSLog(@"success: %@",responseData);
                [MBProgressHUD hideHUDForView:self.view animated:YES];
                [self.navigationController popViewControllerAnimated:YES];
            } failure:^(NSError *error) {
                NSLog(@"error :%@",error);
                [MBProgressHUD showError:@"网络异常"];
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            }];
        }else if (sender.tag == 101){
            NSLog(@"终止收案 ");
            [MBProgressHUD showHUDAddedTo:self.view animated:YES];
            [NetworkingManager postUrl:ALTERCASESTATE_URL dic:@{@"id":self.caseDetailDic[@"id"],@"update_date":@"2017-7-25",@"case_state":@"0"} Succeed:^(id responseData) {
                NSLog(@"success: %@",responseData);
                [MBProgressHUD hideHUDForView:self.view animated:YES];
                [self.navigationController popViewControllerAnimated:YES];
            } failure:^(NSError *error) {
                NSLog(@"error :%@",error);
                [MBProgressHUD showError:@"网络异常"];
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            }];
        }
        
        
    }
    if (self.caseDetailFlag == 1) {
        if (sender.tag == 200) {
            NSLog(@"终止案件 ");
            [MBProgressHUD showHUDAddedTo:self.view animated:YES];
            [NetworkingManager postUrl:ALTERCASESTATE_URL dic:@{@"id":self.caseDetailDic[@"id"],@"update_date":@"2017-7-25",@"case_state":@"0"} Succeed:^(id responseData) {
                NSLog(@"success: %@",responseData);
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            } failure:^(NSError *error) {
                NSLog(@"error :%@",error);
                [MBProgressHUD showError:@"网络异常"];
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            }];
        }
    }
    if (self.caseDetailFlag == 2) {
        if (sender.tag == 300) {
            NSLog(@"结案申请 ");
            [MBProgressHUD showHUDAddedTo:self.view animated:YES];
            [NetworkingManager postUrl:ALTERCASESTATE_URL dic:@{@"id":self.caseDetailDic[@"id"],@"update_date":@"2017-7-25",@"case_state":@"5"} Succeed:^(id responseData) {
                NSLog(@"success: %@",responseData);
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            } failure:^(NSError *error) {
                NSLog(@"error :%@",error);
                [MBProgressHUD showError:@"网络异常"];
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            }];
        }else if (sender.tag == 301){
            NSLog(@"终止案件 ");
            [MBProgressHUD showHUDAddedTo:self.view animated:YES];
            [NetworkingManager postUrl:ALTERCASESTATE_URL dic:@{@"id":self.caseDetailDic[@"id"],@"update_date":@"2017-7-25",@"case_state":@"0"} Succeed:^(id responseData) {
                NSLog(@"success: %@",responseData);
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            } failure:^(NSError *error) {
                NSLog(@"error :%@",error);
                [MBProgressHUD showError:@"网络异常"];
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            }];
        }
    }
    if (self.caseDetailFlag == 4) {
        if (sender.tag == 500) {
            NSLog(@"财务收案审批 ");
            [MBProgressHUD showHUDAddedTo:self.view animated:YES];
            [NetworkingManager postUrl:ALTERCASESTATE_URL dic:@{@"id":self.caseDetailDic[@"id"],@"update_date":@"2017-7-25",@"case_state":@"3"} Succeed:^(id responseData) {
                NSLog(@"success: %@",responseData);
                [self postMessage:sender.tag];
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            } failure:^(NSError *error) {
                NSLog(@"error :%@",error);
                [MBProgressHUD showError:@"网络异常"];
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            }];
        }else if (sender.tag == 501){
            NSLog(@"主任收案通过 ");
            [MBProgressHUD showHUDAddedTo:self.view animated:YES];
            [NetworkingManager postUrl:ALTERCASESTATE_URL dic:@{@"id":self.caseDetailDic[@"id"],@"update_date":@"2017-7-25",@"case_state":@"4"} Succeed:^(id responseData) {
                NSLog(@"success: %@",responseData);
                [self postMessage:sender.tag];
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            } failure:^(NSError *error) {
                NSLog(@"error :%@",error);
                [MBProgressHUD showError:@"网络异常"];
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            }];
        }else if (sender.tag == 502){
            NSLog(@"主任收案不通过 ");
            [MBProgressHUD showHUDAddedTo:self.view animated:YES];
            [NetworkingManager postUrl:ALTERCASESTATE_URL dic:@{@"id":self.caseDetailDic[@"id"],@"update_date":@"2017-7-25",@"case_state":@"-1"} Succeed:^(id responseData) {
                NSLog(@"success: %@",responseData);
                [self postMessage:sender.tag];
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            } failure:^(NSError *error) {
                NSLog(@"error :%@",error);
                [MBProgressHUD showError:@"网络异常"];
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            }];
        }
    }
    if (self.caseDetailFlag == 5) {
        if (sender.tag == 600) {
            NSLog(@"财务收案通过 ");
            [MBProgressHUD showHUDAddedTo:self.view animated:YES];
            [NetworkingManager postUrl:ALTERCASESTATE_URL dic:@{@"id":self.caseDetailDic[@"id"],@"update_date":@"2017-7-25",@"case_state":@"4"} Succeed:^(id responseData) {
                NSLog(@"success: %@",responseData);
                [self postMessage:sender.tag];
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            } failure:^(NSError *error) {
                NSLog(@"error :%@",error);
                [MBProgressHUD showError:@"网络异常"];
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            }];
        }else if (sender.tag == 601){
            NSLog(@"财务收案不通过 ");
            [MBProgressHUD showHUDAddedTo:self.view animated:YES];
            [NetworkingManager postUrl:ALTERCASESTATE_URL dic:@{@"id":self.caseDetailDic[@"id"],@"update_date":@"2017-7-25",@"case_state":@"-1"} Succeed:^(id responseData) {
                NSLog(@"success: %@",responseData);
                [self postMessage:sender.tag];
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            } failure:^(NSError *error) {
                NSLog(@"error :%@",error);
                [MBProgressHUD showError:@"网络异常"];
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            }];
        }
    }
    if (self.caseDetailFlag == 6) {
        if (sender.tag == 700) {
            NSLog(@"财务审批结案 ");
            [MBProgressHUD showHUDAddedTo:self.view animated:YES];
            [NetworkingManager postUrl:ALTERCASESTATE_URL dic:@{@"id":self.caseDetailDic[@"id"],@"update_date":@"2017-7-25",@"case_state":@"6"} Succeed:^(id responseData) {
                NSLog(@"success: %@",responseData);
                [self postMessage:sender.tag];
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            } failure:^(NSError *error) {
                NSLog(@"error :%@",error);
                [MBProgressHUD showError:@"网络异常"];
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            }];
        }else if (sender.tag == 701){
            NSLog(@"主任结案通过 ");
            [MBProgressHUD showHUDAddedTo:self.view animated:YES];
            [NetworkingManager postUrl:ALTERCASESTATE_URL dic:@{@"id":self.caseDetailDic[@"id"],@"update_date":@"2017-7-25",@"case_state":@"7"} Succeed:^(id responseData) {
                NSLog(@"success: %@",responseData);
                [self postMessage:sender.tag];
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            } failure:^(NSError *error) {
                NSLog(@"error :%@",error);
                [MBProgressHUD showError:@"网络异常"];
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            }];
        }else if (sender.tag == 702){
            NSLog(@"主任结案不通过 ");
            [MBProgressHUD showHUDAddedTo:self.view animated:YES];
            [NetworkingManager postUrl:ALTERCASESTATE_URL dic:@{@"id":self.caseDetailDic[@"id"],@"update_date":@"2017-7-25",@"case_state":@"-4"} Succeed:^(id responseData) {
                NSLog(@"success: %@",responseData);
                [self postMessage:sender.tag];
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            } failure:^(NSError *error) {
                NSLog(@"error :%@",error);
                [MBProgressHUD showError:@"网络异常"];
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            }];
        }
    }
    if (self.caseDetailFlag == 7) {
        if (sender.tag == 800) {
            NSLog(@"财务结案通过 ");
            [MBProgressHUD showHUDAddedTo:self.view animated:YES];
            [NetworkingManager postUrl:ALTERCASESTATE_URL dic:@{@"id":self.caseDetailDic[@"id"],@"update_date":@"2017-7-25",@"case_state":@"7"} Succeed:^(id responseData) {
                NSLog(@"success: %@",responseData);
                [self postMessage:sender.tag];
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            } failure:^(NSError *error) {
                NSLog(@"error :%@",error);
                [MBProgressHUD showError:@"网络异常"];
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            }];
        }else if (sender.tag == 801){
            NSLog(@"财务结案不通过 ");
            [MBProgressHUD showHUDAddedTo:self.view animated:YES];
            [NetworkingManager postUrl:ALTERCASESTATE_URL dic:@{@"id":self.caseDetailDic[@"id"],@"update_date":@"2017-7-25",@"case_state":@"-4"} Succeed:^(id responseData) {
                NSLog(@"success: %@",responseData);
                [self postMessage:sender.tag];
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            } failure:^(NSError *error) {
                NSLog(@"error :%@",error);
                [MBProgressHUD showError:@"网络异常"];
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            }];
        }
    }
}
- (void)toNext:(UIButton *)sender{
    NSLog(@"111%@",self.caseDetailDic);
    IntroduceViewController *caseIntroduceVC = [[IntroduceViewController alloc] init];
    caseIntroduceVC.caseTypeStr = self.ajlxArr[[self.caseDetailDic[@"ajlx"] integerValue] - 1];
    caseIntroduceVC.flag = [self.caseDetailDic[@"ajlx"] integerValue];
    caseIntroduceVC.ajlx = [self.caseDetailDic[@"ajlx"] integerValue];
    caseIntroduceVC.ajfl = [self.caseDetailDic[@"ajlx"] integerValue];
    caseIntroduceVC.caseDetailDic = self.caseDetailDic;
    [self.navigationController pushViewController:caseIntroduceVC animated:YES];
}


#pragma mark - UITableViewDelegate/UITableViewDataSource
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 45;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 50;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.titleArray.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 215;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    CaseDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:@"caseCell" forIndexPath:indexPath];
    cell.titleLable.text = self.titleArray[indexPath.row];
    cell.titleImageView.image = [UIImage imageNamed:self.imageArray[indexPath.row]];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 80)];
    footerView.backgroundColor = [UIColor whiteColor];
    if (self.caseDetailFlag == 0) {
        NSArray *arr = @[@"收案申请",@"终止收案"];
        for (int i = 0; i < arr.count; i ++) {
            UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(50 + i * 170, 15, 100, 50)];
            button.backgroundColor = [UIColor colorWithRed:33.0f/255.0f green:180.0f/255.0f blue:237.0f/255.0f alpha:1.0f];
            [button setTitle:arr[i] forState:0];
            button.titleLabel.textColor = [UIColor whiteColor];
            button.tag = button.tag = (self.caseDetailFlag + 1) * 100 + i;
            [button addTarget:self action:@selector(action_Click:) forControlEvents:UIControlEventTouchUpInside];
            button.layer.cornerRadius = 5;
            button.layer.masksToBounds = YES;
            [footerView addSubview:button];
        }
    }
    if (self.caseDetailFlag == 1) {
        NSArray *arr = @[@"终止收案"];
        for (int i = 0; i < arr.count; i ++) {
            UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(25, 15, 320, 50)];
            button.backgroundColor = [UIColor colorWithRed:33.0f/255.0f green:180.0f/255.0f blue:237.0f/255.0f alpha:1.0f];
            [button setTitle:arr[i] forState:0];
            button.titleLabel.textColor = [UIColor whiteColor];
            button.tag = button.tag = (self.caseDetailFlag + 1) * 100 + i;
            [button addTarget:self action:@selector(action_Click:) forControlEvents:UIControlEventTouchUpInside];
            button.layer.cornerRadius = 5;
            button.layer.masksToBounds = YES;
            [footerView addSubview:button];
        }
    }
    if (self.caseDetailFlag == 2) {
        NSArray *arr = @[@"结案申请",@"终止结案"];
        for (int i = 0; i < arr.count; i ++) {
            UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(50 + i * 170, 15, 100, 50)];
            button.backgroundColor = [UIColor colorWithRed:33.0f/255.0f green:180.0f/255.0f blue:237.0f/255.0f alpha:1.0f];
            [button setTitle:arr[i] forState:0];
            button.titleLabel.textColor = [UIColor whiteColor];
            button.tag = button.tag = (self.caseDetailFlag + 1) * 100 + i;
            [button addTarget:self action:@selector(action_Click:) forControlEvents:UIControlEventTouchUpInside];
            button.layer.cornerRadius = 5;
            button.layer.masksToBounds = YES;
            [footerView addSubview:button];
        }
    }
    if (self.caseDetailFlag == 4 || self.caseDetailFlag == 6) {
        NSArray *arr = @[@"财务审批",@"通过",@"不通过"];
        for (int i = 0; i < arr.count; i ++) {
            UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(15 + i * 120, 15, 100, 50)];
            button.backgroundColor = [UIColor colorWithRed:33.0f/255.0f green:180.0f/255.0f blue:237.0f/255.0f alpha:1.0f];
            [button setTitle:arr[i] forState:0];
            button.titleLabel.textColor = [UIColor whiteColor];
            button.tag = (self.caseDetailFlag + 1) * 100 + i;
            [button addTarget:self action:@selector(action_Click:) forControlEvents:UIControlEventTouchUpInside];
            button.layer.cornerRadius = 5;
            button.layer.masksToBounds = YES;
            [footerView addSubview:button];
        }
    }
    if (self.caseDetailFlag == 5 || self.caseDetailFlag == 7) {
        NSArray *arr = @[@"通过",@"不通过"];
        for (int i = 0; i < arr.count; i ++) {
            UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(50 + i * 170, 15, 100, 50)];
            button.backgroundColor = [UIColor colorWithRed:33.0f/255.0f green:180.0f/255.0f blue:237.0f/255.0f alpha:1.0f];
            [button setTitle:arr[i] forState:0];
            button.titleLabel.textColor = [UIColor whiteColor];
            button.tag = (self.caseDetailFlag + 1) * 100 + i;
            [button addTarget:self action:@selector(action_Click:) forControlEvents:UIControlEventTouchUpInside];
            button.layer.cornerRadius = 5;
            button.layer.masksToBounds = YES;
            [footerView addSubview:button];
        }
    }
    return footerView;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSInteger row = indexPath.row;
    if (self.caseDetailFlag == 0) {
        if (indexPath.row == 0) {
            ChargingInfoViewController *chargingInfoVC = [[ChargingInfoViewController alloc] init];
            chargingInfoVC.log = row;
            chargingInfoVC.hideOrNot = NO;
            chargingInfoVC.caseDetailDic = self.caseDetailDic;
            [self.navigationController pushViewController:chargingInfoVC animated:YES];
        }
        if (indexPath.row == 1) {
            JobLogViewController *jobLogVC = [[JobLogViewController alloc] init];
            jobLogVC.log = row;
            jobLogVC.hideOrNot = NO;
            jobLogVC.caseDetailDic = self.caseDetailDic;
            [self.navigationController pushViewController:jobLogVC animated:YES];
        }
        if (indexPath.row == 2) {
            InspectionOfficeViewController *inspectionOfficeVC = [[InspectionOfficeViewController alloc] init];
            inspectionOfficeVC.log = row;
            inspectionOfficeVC.hideOrNot = NO;
            inspectionOfficeVC.caseDetailDic = self.caseDetailDic;
            [self.navigationController pushViewController:inspectionOfficeVC animated:YES];
            
        }
        if (indexPath.row == 3) {
            InvestigativeOrganViewController *investigativeOrganVC = [[InvestigativeOrganViewController alloc] init];
            investigativeOrganVC.log = row;
            investigativeOrganVC.hideOrNot = NO;
            investigativeOrganVC.caseDetailDic = self.caseDetailDic;
            [self.navigationController pushViewController:investigativeOrganVC animated:YES];
        }
        if (indexPath.row == 4) {
            CourtViewController *courtVC = [[CourtViewController alloc] init];
            courtVC.log = row;
            courtVC.hideOrNot = NO;
            courtVC.caseDetailDic = self.caseDetailDic;
            [self.navigationController pushViewController:courtVC animated:YES];
        }
    }else{
        if (indexPath.row == 0) {
            ChargingInfoViewController *chargingInfoVC = [[ChargingInfoViewController alloc] init];
            chargingInfoVC.log = row;
            chargingInfoVC.hideOrNot = YES;
            chargingInfoVC.caseDetailDic = self.caseDetailDic;
            [self.navigationController pushViewController:chargingInfoVC animated:YES];
        }
        if (indexPath.row == 1) {
            JobLogViewController *jobLogVC = [[JobLogViewController alloc] init];
            jobLogVC.log = row;
            jobLogVC.hideOrNot = YES;
            jobLogVC.caseDetailDic = self.caseDetailDic;
            [self.navigationController pushViewController:jobLogVC animated:YES];
        }
        if (indexPath.row == 2) {
            InspectionOfficeViewController *inspectionOfficeVC = [[InspectionOfficeViewController alloc] init];
            inspectionOfficeVC.log = row;
            inspectionOfficeVC.hideOrNot = YES;
            inspectionOfficeVC.caseDetailDic = self.caseDetailDic;
            [self.navigationController pushViewController:inspectionOfficeVC animated:YES];
            
        }
        if (indexPath.row == 3) {
            InvestigativeOrganViewController *investigativeOrganVC = [[InvestigativeOrganViewController alloc] init];
            investigativeOrganVC.log = row;
            investigativeOrganVC.hideOrNot = YES;
            investigativeOrganVC.caseDetailDic = self.caseDetailDic;
            [self.navigationController pushViewController:investigativeOrganVC animated:YES];
        }
        if (indexPath.row == 4) {
            CourtViewController *courtVC = [[CourtViewController alloc] init];
            courtVC.log = row;
            courtVC.hideOrNot = YES;
            courtVC.caseDetailDic = self.caseDetailDic;
            [self.navigationController pushViewController:courtVC animated:YES];
        }
    }
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 200)];
    
    UIView *caseView = [[UIView alloc] initWithFrame:CGRectMake(0, 5, self.view.bounds.size.width , 50)];
    caseView.backgroundColor = [UIColor colorWithRed:248.0f/255.0f green:248.0f/255.0f blue:248.0f/255.0f alpha:1.0f];
//    caseView.layer.cornerRadius = 5;
//    caseView.layer.masksToBounds = YES;
    
    UIImageView *titleImageView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 15, 20, 20)];
    titleImageView.image = [UIImage imageNamed:@"my.png"];
//    titleImageView.backgroundColor = [UIColor redColor];
    
    UIImageView *arrowImageView = [[UIImageView alloc] initWithFrame:CGRectMake(330, 15, 30, 20)];
    arrowImageView.image = [UIImage imageNamed:@"箭头"];
//    arrowImageView.backgroundColor = [UIColor redColor];
    
    UILabel *caseTitleLable = [[UILabel alloc] initWithFrame:CGRectMake(55, 5, 240, 40)];
    
    caseTitleLable.text = self.caseDetailDic[@"ay"];//后期传值
    caseTitleLable.textColor = [UIColor blackColor];
    caseTitleLable.font = [UIFont systemFontOfSize:15];
    
    
    UIButton *caseButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 135)];
    [caseButton addTarget:self action:@selector(toNext:) forControlEvents:UIControlEventTouchUpInside];
    
    
    UIView *lawyerView = [[UIView alloc] initWithFrame:CGRectMake(0, 135, self.view.bounds.size.width , 50)];
    lawyerView.backgroundColor = [UIColor colorWithRed:248.0f/255.0f green:248.0f/255.0f blue:248.0f/255.0f alpha:1.0f];
//    lawyerView.layer.cornerRadius = 5;
//    lawyerView.layer.masksToBounds = YES;
    
    UIImageView *lawyerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 15, 20, 20)];
    lawyerImageView.image = [UIImage imageNamed:@"my.png"];
//    lawyerImageView.backgroundColor = [UIColor redColor];
    
    
    UILabel *lawyerTitleLable = [[UILabel alloc] initWithFrame:CGRectMake(55, 5, 240, 40)];
    
    lawyerTitleLable.text = @"办案律师 ";//后期传值
    lawyerTitleLable.textColor = [UIColor blackColor];
    lawyerTitleLable.font = [UIFont systemFontOfSize:15];
    
    UILabel *lawyerLable = [[UILabel alloc ]initWithFrame:CGRectMake(5, 190, 200, 20)];
    lawyerLable.text = [NSString stringWithFormat:@"律师： %@",self.caseDetailDic[@"name"]];//传值
    lawyerLable.font = [UIFont systemFontOfSize:11];
    
    
    
    [header addSubview:lawyerView];
    [header addSubview:caseView];
    [header addSubview:lawyerLable];
    [header addSubview:caseButton];
    
    for (int i = 0; i < 2; i ++) {
        UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 5 + i * 130 , self.view.bounds.size.width , 1)];
        lineView.backgroundColor = [UIColor colorWithRed:238.0f/255.0f green:238.0f/255.0f blue:238.0f/255.0f alpha:1.0f];
        [header addSubview:lineView];
    }
    
    [caseView addSubview:caseTitleLable];
    [caseView addSubview:titleImageView];
    [caseView addSubview:arrowImageView];
    [lawyerView addSubview:lawyerImageView];
    [lawyerView addSubview:lawyerTitleLable];
    
    
    for (int i = 0 ; i <= 3; i ++) {
        UILabel *infoLable = [[UILabel alloc] initWithFrame:CGRectMake(5, 55 + i * 20, 300, 20)];
        infoLable.font = [UIFont systemFontOfSize:11];
        if (i == 0) {
            infoLable.text = [NSString stringWithFormat:@"案       号： %@",self.caseDetailDic[@"ah_number"]];
        }
        else if (i == 1) {
            infoLable.text = [NSString stringWithFormat:@"代   理   费： %@",self.caseDetailDic[@"dlf"]];
        }
        else if (i == 2) {
            NSString *key = self.caseDetailDic[@"sffs"];
            NSString *tollMethod = self.tollMethod[key];
            infoLable.text = [NSString stringWithFormat:@"收费方式： %@",tollMethod];
        }
        else if (i == 3) {
            infoLable.text = [NSString stringWithFormat:@"收案日期： %@",self.caseDetailDic[@"sarq"]];
        }
        [header addSubview:infoLable];
    }
    
    
    
    
    
    return header;
}
#pragma mark - Getter
- (NSArray *)titleArray{
    if (!_titleArray) {
        _titleArray = [NSArray arrayWithObjects:@"收款信息 ",@"工作日志 ",@"侦查机关 ",@"检察机关 ",@"法庭开庭 ", nil];
    }
    return _titleArray;
}
- (NSArray *)imageArray{
    if (!_imageArray) {
        _imageArray = [NSArray arrayWithObjects:@"caseform02",@"caseform06",@"caseform03",@"caseform05",@"caseform04", nil];
    }
    return _imageArray;
}
- (NSDictionary *)tollMethod{
    if (!_tollMethod) {
        _tollMethod = [NSDictionary dictionaryWithObjectsAndKeys:@"免费",@"0",@"计件收费",@"1",@"按标的比例收费",@"2",@"风险代理收费",@"3",@"固定+风险代理收费",@"4", nil];
    }
    return _tollMethod;
}
- (NSArray *)ajlxArr{
    if (!_ajlxArr) {
        _ajlxArr = [NSArray arrayWithObjects:@"民事案件",@"刑事案件",@"行政案件",@"非诉讼法律事物",@"法律顾问",@"执行案件",@"中保案件",@"仲裁案件",@"破产案件",@"咨询代写律师", nil];
    }
    return _ajlxArr;
}
- (UITableView *)caseTableView{
    if (!_caseTableView) {
        _caseTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH , SCREEN_HEIGHT - 64) style:UITableViewStyleGrouped];
        _caseTableView.backgroundColor = [UIColor whiteColor];
        _caseTableView.delegate = self;
        _caseTableView.dataSource = self;
        _caseTableView.estimatedRowHeight = 10;
        _caseTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [_caseTableView registerClass:[CaseDetailCell class] forCellReuseIdentifier:@"caseCell"];
    }
    return _caseTableView;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
